<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp_lib/init.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>权限管理</title>
<jsp:include page="/WEB-INF/jsp/common/common.jsp" />
<jsp:include page="/WEB-INF/jsp_lib/extjs.jsp" />

<script type="text/javascript">
	Ext.onReady(function() {
		Ext.create('Ext.form.Panel', {
			title : '备份',
			width : 400,
			bodyPadding : 10,
			frame : true,
			renderTo : Ext.getBody(),
			/* defaultType : "textfield",
			items : [ {
				fieldLabel : '数据库名称',
				name : "name",
				allowBlank : false
			}, {
				fieldLabel : '数据库登录名',
				name : "uname",
				allowBlank : false
			}, {
				fieldLabel : '数据库登录密码',
				name : "pwd",
				allowBlank : false
			} ], */
			buttons : [ /**{
						text : '数据库备份',
						handler : function() {
							var form = this.up('form').getForm();
							if (form.isValid()) {
								form.submit({
									url : '${path}/cp/database/backup.htm',
									waitMsg : '备份中...',
									success : function(form, action) {
										Ext.Msg.alert("提示", action.result.tip.msg);
									},
									failure : function(form, action) {
										Ext.Msg.alert("提示", action.result.tip.msg);
									}
								});
							}
						}
					}, **/
			{
				text : '系统备份包下载',
				handler : function() {
					var form = this.up('form').getForm();
					if (form.isValid()) {
						form.submit({
							url : 'backup_all.htm',
							waitMsg : '备份中...',
							success : function(form, action) {
								if (action.result.file_zip != undefined) {
									window.location.href = "backup_all_download.htm?file_zip=" + action.result.file_zip;
								} else {
									Ext.Msg.alert("提示", action.result.tip.msg);
								}

							},
							failure : function(form, action) {
								Ext.Msg.alert("提示", action.result.tip.msg);
							}
						});
					}
				}

			} ]
		});

		Ext.create('Ext.form.Panel', {
			title : '还原',
			width : 400,
			bodyPadding : 10,
			style : "margin-top:10px",
			frame : true,
			renderTo : Ext.getBody(),
			items : [ {
				xtype : 'filefield',
				name : 'addr',
				fieldLabel : '数据库',
				labelWidth : 50,
				msgTarget : 'side',
				allowBlank : false,
				anchor : '100%',
				buttonText : '选择系统包文件'
			} ],

			buttons : [ {
				text : '还原整个系统',
				handler : function() {
					var form = this.up('form').getForm();
					if (form.isValid()) {

						Ext.Msg.confirm("提示:", "系统还原将删掉所有的数据库与文件,望慎重! 如果必要,请先操作 【系统备份包下载】,将备份包下载到您的本地.", function(e) {
							if (e == "yes") {
								form.submit({
									url : '${path}/cp/database/restore_all.htm',
									waitMsg : '还原中,切勿操作任何项目!!! 稍后会有结果...',
									success : function(form, action) {
										Ext.Msg.alert("提示", action.result.tip.msg);
									},
									failure : function(form, action) {
										Ext.Msg.alert("提示", action.result.tip.msg);
									}
								});
							}//#if yes
						});

					}//#if
				}//#handler 
			} ]
		});
	});
</script>
</head>
<body>

</body>
</html>